package com.codecrane.core.util;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 公共工具类
 *
 * @author Crane(hehebaiy@gmail.com)
 *         <br/>
 *         <br/>
 */
public class PdfReadUtils {

    public static String readPdfSku(String text) {
        String regex = "Single SKU\\s*(\\S+)";
        String singleSKU ="";
        // 创建Pattern对象
        Pattern pattern = Pattern.compile(regex);

        // 创建Matcher对象
        Matcher matcher = pattern.matcher(text);

        // 查找匹配的文本
        if (matcher.find()) {
            // 提取并打印"Single SKU"后面的文本
            singleSKU = matcher.group(1);
            System.out.println("Single SKU: " + singleSKU);
        } else {
            System.out.println("No Single SKU found.");
        }
        System.out.println("--------------------------------------------------");
        return singleSKU;
    }

    public static String readPdfSku2(String text) {
        String regex = "Einzelne SKU\\s*(\\S+)";
        String singleSKU ="";
        // 创建Pattern对象
        Pattern pattern = Pattern.compile(regex);

        // 创建Matcher对象
        Matcher matcher = pattern.matcher(text);

        // 查找匹配的文本
        if (matcher.find()) {
            // 提取并打印"Single SKU"后面的文本
            singleSKU = matcher.group(1);
            System.out.println("Single SKU: " + singleSKU);
        } else {
            System.out.println("No Single SKU found.");
        }
        System.out.println("--------------------------------------------------");
        return singleSKU;
    }
    public static String readPdfNumber(String text) {
        String regex = "数量\\s*(\\d+)";
        String singleSKU ="";
        // 创建Pattern对象
        Pattern pattern = Pattern.compile(regex);

        // 创建Matcher对象
        Matcher matcher = pattern.matcher(text);

        // 查找匹配的文本
        if (matcher.find()) {
            // 提取并打印"Single SKU"后面的文本
            singleSKU = matcher.group(1);
            System.out.println("数量: " + singleSKU);
        } else {
            System.out.println("No Single SKU found.");
        }
        System.out.println("--------------------------------------------------");
        return singleSKU;
    }

    public static String readPdfShipmentId(String text) {
        String regex = "(?m)^(.*)\\r?\\nSingle SKU$";
        String singleSKU ="";
        // 创建Pattern对象
        Pattern pattern = Pattern.compile(regex);

        // 创建Matcher对象
        Matcher matcher = pattern.matcher(text);

        // 查找匹配的文本
        if (matcher.find()) {
            // 提取并打印"Single SKU"后面的文本
            singleSKU = matcher.group(1);
            System.out.println("数量: " + singleSKU);
        } else {
            System.out.println("No Single SKU found.");
        }
        System.out.println("--------------------------------------------------");
        return singleSKU;
    }



}
